home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / crccalcc / mainform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-12  |  4.4 KB  |  152 lines

  1. VERSION 5.00
  2. Object = "{5E969A41-5923-11D0-B191-444553540000}#1.0#0"; "CRCCTRL.OCX"
  3. Begin VB.Form mainform 
  4.    BackColor       =   &H00E0E0E0&
  5.    Caption         =   "Test CRC OCX"
  6.    ClientHeight    =   2565
  7.    ClientLeft      =   1200
  8.    ClientTop       =   1695
  9.    ClientWidth     =   4500
  10.    ForeColor       =   &H00404040&
  11.    LinkTopic       =   "Form1"
  12.    PaletteMode     =   1  'UseZOrder
  13.    Picture         =   "mainform.frx":0000
  14.    ScaleHeight     =   2565
  15.    ScaleWidth      =   4500
  16.    Begin VB.ComboBox crclist 
  17.       Height          =   315
  18.       ItemData        =   "mainform.frx":0446
  19.       Left            =   150
  20.       List            =   "mainform.frx":0462
  21.       TabIndex        =   8
  22.       Text            =   "Crc type"
  23.       Top             =   1470
  24.       Width           =   4185
  25.    End
  26.    Begin VB.CommandButton cmdVisible 
  27.       Caption         =   "Hide"
  28.       Height          =   495
  29.       Left            =   120
  30.       TabIndex        =   6
  31.       Top             =   1980
  32.       Width           =   1305
  33.    End
  34.    Begin VB.CommandButton cmdExit 
  35.       Cancel          =   -1  'True
  36.       Caption         =   "Exit"
  37.       Default         =   -1  'True
  38.       Height          =   495
  39.       Left            =   3030
  40.       TabIndex        =   1
  41.       Top             =   1980
  42.       Width           =   1305
  43.    End
  44.    Begin VB.CommandButton cmdDoCRC 
  45.       Caption         =   "Do CRC"
  46.       Height          =   495
  47.       Left            =   1590
  48.       TabIndex        =   0
  49.       Top             =   1980
  50.       Width           =   1305
  51.    End
  52.    Begin CRCCTRLLib.CrcCtrl crcTest 
  53.       Height          =   405
  54.       Left            =   120
  55.       TabIndex        =   7
  56.       Top             =   870
  57.       Width           =   4185
  58.       _Version        =   65537
  59.       _ExtentX        =   7382
  60.       _ExtentY        =   714
  61.       _StockProps     =   0
  62.       CRCType         =   6
  63.    End
  64.    Begin VB.Label Label2 
  65.       Caption         =   "CRC"
  66.       Height          =   285
  67.       Left            =   120
  68.       TabIndex        =   5
  69.       Top             =   450
  70.       Width           =   1545
  71.    End
  72.    Begin VB.Label Label1 
  73.       Caption         =   "Speed"
  74.       Height          =   285
  75.       Left            =   120
  76.       TabIndex        =   4
  77.       Top             =   120
  78.       Width           =   1545
  79.    End
  80.    Begin VB.Label lblticks 
  81.       Caption         =   " "
  82.       Height          =   285
  83.       Left            =   1710
  84.       TabIndex        =   3
  85.       Top             =   120
  86.       Width           =   2595
  87.    End
  88.    Begin VB.Label lblResult 
  89.       Caption         =   "0"
  90.       Height          =   285
  91.       Left            =   1710
  92.       TabIndex        =   2
  93.       Top             =   450
  94.       Width           =   2595
  95.    End
  96. Attribute VB_Name = "mainform"
  97. Attribute VB_GlobalNameSpace = False
  98. Attribute VB_Creatable = False
  99. Attribute VB_PredeclaredId = True
  100. Attribute VB_Exposed = False
  101. Option Explicit
  102. Dim Data As String
  103. Dim Cnt As Long
  104. Dim Seed As Long
  105. Dim tickstart As Long
  106. Private Sub cmdDoCRC_Click()
  107.     lblticks = "Stated"
  108.     tickstart = GetTickCount
  109.     lblResult = Hex(crcTest.DoCRC(Data, Cnt, False, Seed))
  110.     lblticks = Str((GetTickCount - tickstart) * (1048576 * 0.001 / Cnt)) & " secs/MB"
  111. End Sub
  112. Private Sub cmdExit_Click()
  113. Unload Me
  114. End Sub
  115. Public Function StrAddress(ByVal StrRef As Long) As Long
  116.     StrAddress = CLng(StrRef)
  117. End Function
  118. Private Sub cmdVisible_Click()
  119.     If cmdVisible.Caption = "Show" Then
  120.         cmdVisible.Caption = "Hide"
  121.         crcTest.Visible = True
  122.     Else
  123.         cmdVisible.Caption = "Show"
  124.         crcTest.Visible = False
  125.     End If
  126. End Sub
  127. Private Sub crclist_Click()
  128.     crcTest.CRCType = crclist.ListIndex
  129. End Sub
  130. Private Sub Form_Load()
  131.     Dim mbytes As Single
  132.     crclist.ListIndex = crcTest.CRCType
  133.     mbytes = 0.25
  134.     'Cnt = mbytes * 1048576
  135.     'Data = "Hello" & String(mbytes * 1048576, Chr(0))
  136.     Dim fnum As Integer
  137.     fnum = FreeFile
  138.     Open "testdata.dat" For Binary Access Read As #fnum
  139.     Cnt = LOF(fnum)
  140.     If Cnt = 0 Then
  141.         MsgBox "require a data file call testdat.dat with some data"
  142.         End
  143.     End If
  144.     Data = String(Cnt, Chr(0))
  145.     Get #fnum, , Data
  146.     Close #fnum
  147.     fnum = FreeFile
  148.     Open "testdata.out" For Binary Access Write As #fnum
  149.     Put #fnum, , Data
  150.     Close #fnum
  151. End Sub
  152.